var t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), e = require("../../../@babel/runtime/helpers/asyncToGenerator"), a = require("../../../poster/poster"), s = getApp();

Component({
    behaviors: [ a ],
    properties: {
        activeID: {
            value: 0,
            type: Number
        },
        store_id: {
            value: 0,
            type: Number
        }
    },
    data: {
        listData: {}
    },
    observers: {
        isshow: function(t) {
            console.log("==============", this.data.listData[this.data.activeID], this.properties.activeID), 
            t && !this.data.listData[this.data.activeID] && this.data.getFlag ? (this.data.getFlag = !1, 
            this.getPosterPic()) : "" != this.data.listData[this.data.activeID] && this.setData({
                poster: this.data.listData[this.data.activeID]
            });
        }
    },
    methods: {
        getPosterPic: function() {
            var a = this;
            return e(t.default.mark(function e() {
                var r, i;
                return t.default.wrap(function(t) {
                    for (;;) switch (t.prev = t.next) {
                      case 0:
                        r = s.getNetAddresss("plugin.fight-groups.frontend.controllers.group-poster.generate-goods-poster"), 
                        a.setData({
                            poster: ""
                        }), i = a, s._getNetWork({
                            showToastIn: !1,
                            url: r,
                            data: {
                                id: i.properties.activeID,
                                store_id: i.data.store_id
                            },
                            success: function(t) {
                                var e = t.data;
                                1 == e.result ? (a.data.listData[a.data.data] = e.data.image_url, a.setData({
                                    poster: e.data.image_url
                                })) : wx.showToast({
                                    title: e.msg
                                });
                            },
                            complete: function() {
                                a.data.getFlag = !0;
                            }
                        });

                      case 4:
                      case "end":
                        return t.stop();
                    }
                }, e);
            }))();
        },
        saveImg: function() {
            console.log("执行", this.data.poster);
            var t = this.data.poster, e = wx.env.USER_DATA_PATH + "/solitaire_qrcodehaibao.png", a = t.replace(/^data:image\/\w+;base64,/, ""), s = wx.getFileSystemManager();
            s.writeFileSync(e, a, "base64"), wx.saveImageToPhotosAlbum({
                filePath: e,
                success: function(t) {
                    s.unlinkSync(e), wx.showToast({
                        title: "保存成功",
                        icon: "none",
                        duration: 2e3
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    }
});